<template>
  <div class="h5">
    <h2>h5版本</h2>
    <p>产品类型、aafaa454561</p>
    <el-row>
      <el-col :span="24" class="addBtn">
        <el-button class="addH5" type="success" @click="dialogFormVisible = true">新增H5</el-button>
      </el-col>
    </el-row>
    <el-table :data="h5Data" style="width: 100%" class="h5Table">
      <el-table-column prop="filename" label="文件名"></el-table-column>
      <el-table-column prop="version" label="版本号"></el-table-column>
      <el-table-column prop="date" label="日期"></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">下载</el-button>
          <el-button size="mini" @click="handleDelete(scope.$index, scope.row)">启用</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-dialog :visible.sync="dialogFormVisible">
      <el-form :model="form">
        <el-form-item label="产品名称" :label-width="formLabelWidth">
          <el-select v-model="value" placeholder="请选择">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="H5版本" :label-width="formLabelWidth">
          <el-input v-model="form.name" autocomplete="off" placeholder="请输入H5版本"></el-input>
        </el-form-item>
        <el-form-item label="选择文件" :label-width="formLabelWidth">
          <el-upload
            class="avatar-uploader"
            action="https://jsonplaceholder.typicode.com/posts/"
            :show-file-list="false"
            :on-success="handleAvatarSuccess"
            :before-upload="beforeAvatarUpload"
          >
            <img v-if="imageUrl" :src="imageUrl" class="avatar">
            <el-button v-else plain>上传文件</el-button>
          </el-upload>
        </el-form-item>
        <el-form-item label="版本描述" :label-width="formLabelWidth">
          <el-input
            type="textarea"
            :autosize="{ minRows: 2, maxRows: 4}"
            placeholder="请输入版本描述"
            v-model="form.desc"
          ></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "home",
  data() {
    return {
      h5Data: [
        {
          filename: "0000001",
          version: "1.0",
          date: "201810241505"
        }
      ],
      gridData: [
        {
          date: "2016-05-02",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄"
        },
        {
          date: "2016-05-04",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄"
        },
        {
          date: "2016-05-01",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄"
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄"
        }
      ],
      dialogTableVisible: false,
      dialogFormVisible: false,
      form: {
        name: "",
        region: "",
        date1: "",
        date2: "",
        delivery: false,
        type: [],
        resource: "",
        desc: "",
      },
      formLabelWidth: "120px",
      imageUrl: "",
      options: [{
          value: '选项1',
          label: '黄金糕'
        }, {
          value: '选项2',
          label: '双皮奶'
        }, {
          value: '选项3',
          label: '蚵仔煎'
        }, {
          value: '选项4',
          label: '龙须面'
        }, {
          value: '选项5',
          label: '北京烤鸭'
        }],
        value: ''
    };
  },
  methods: {
    handleEdit(index, row) {
      console.log(index, row);
    },
    handleDelete(index, row) {
      console.log(index, row);
    },
    handleAvatarSuccess() {},
    beforeAvatarUpload() {}
  }
};
</script>

<style lang="less">
@import "../../style/color.less";
.h5 {
  h2 {
    text-align: left;
    margin-bottom: 20px;
  }
  p {
    text-align: left;
  }
  .addBtn {
    text-align: right;
    .addH5 {
      background-color: @themeColor;
      border-color: @themeColor;
    }
  }
  .h5Table {
    margin-top: 20px;
    border-top: 1px solid #ebeef5;
  }
  .el-form-item__content{
    text-align: left;
  }
}
</style>